package com.situ.storehouse.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.situ.storehouse.entity.Attendant;
import com.situ.storehouse.service.AttendantService;
import com.situ.storehouse.service.AttendantServiceImpl;
import com.situ.storehouse.util.BaseController;
import com.situ.storehouse.vo.LayuiTableVO;
import com.situ.storehouse.vo.ResultVO;

//管理员管理控制类
@WebServlet("/attendantcontroller")
public class AttendantController extends BaseController{
	private static final long serialVersionUID = 1L;
	AttendantService service=new AttendantServiceImpl();
	//打开会员管理界面
	public void page(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.getRequestDispatcher("/WEB-INF/attendant.jsp").forward(request, response);
	}
	
	//往表格中放数据
	public LayuiTableVO list(Integer page,Integer limit,String keyword){
		List<Attendant> list=service.select(page,limit,keyword);
		LayuiTableVO vo=new LayuiTableVO();
		vo.setCode(0);
		vo.setData(list);
		vo.setCount(service.count(keyword));
		return vo;
	}
	
	//删除数据
	public void delete(Integer id) {
		service.delete(id);
	}
	
	//查询某个员工信息
	public ResultVO select(Integer id){
		return service.select(id);
		}

	//增加+修改员工信息
	public ResultVO save(Attendant attendant) {
		ResultVO vo= service.save(attendant);
		return vo;
	}
}
